package com.niuquan.adapter;

import android.annotation.SuppressLint;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.niuquan.activitie.R;
import com.niuquan.modal.Remind;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


public class infoAdapter extends BaseAdapter {
    private LayoutInflater mInflater;
	private ArrayList<Remind> appList;
    private List<Map<String, Object>> mData;
    public static Map<Integer, Boolean> isSelected;
    public String Ot = "others";
    public String St = "study";
    public String Sp = "sport";
    public String En = "entertain";
    public String Jr = "journy";

    public infoAdapter(Context context,ArrayList<Remind> List) {
        mInflater = LayoutInflater.from(context);
        appList = List;
        init();
    }

    // ��ʼ��
    private void init() {
        mData = new ArrayList<Map<String, Object>>();
        for (int i = 0; i < appList.size(); i++) {
//            String name = (String) actlistSt.get(i).name;
//            String date = (String) actlistSt.get(i).date;
//            String type = (String) actlistSt.get(i).type;
//            int type_id = (int)actlistSt.get(i).type_id;
//            String tmpType = "��";
//            int id = (int) actlistSt.get(i).id;
//            int peoplenum= (int)actlistSt.get(i).people;
        	
            Map<String, Object> map = new HashMap<String, Object>();
            String title = (String) appList.get(i).getTitle();
            String publisber = String.valueOf(appList.get(i).getPublisher());
            String timep =  appList.get(i).getTime();
            String coins = appList.get(i).getCoins();


           int inum = i+1;
            map.put("title", title);
            map.put("publisber", publisber);
            map.put("timep", timep);
            map.put("coins", coins);
            mData.add(map);
        }
        /*
         * // �������isSelected���map�Ǽ�¼ÿ��listitem��״̬����ʼ״̬ȫ��Ϊfalse�� isSelected = new
         * HashMap<Integer, Boolean>(); for (int i = 0; i < mData.size(); i++) {
         * isSelected.put(i, false); }
         */
    }

    @Override
    public int getCount() {
        return mData.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @SuppressLint("ResourceAsColor")
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;

        if (convertView == null) {
            holder = new ViewHolder();
            convertView = mInflater.inflate(R.layout.layout_remind_item, null);
            holder.title = (TextView) convertView.findViewById(R.id.awx_title);
            holder.publisher = (TextView) convertView.findViewById(R.id.awx_publisher);
            holder.timepoint = (TextView) convertView.findViewById(R.id.awx_time_point);
            holder.coins = (TextView) convertView.findViewById(R.id.awx_coin);

            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        
        int tmp = (Integer) mData.get(position).get("typeId");

        holder.title.setText(mData.get(position).get("title").toString());
        holder.publisher.setText(mData.get(position).get("publisher").toString());
        holder.timepoint.setText(mData.get(position).get("timep").toString());
        holder.coins.setText(mData.get(position).get("coins").toString());
       
        //holder.type.setText(mData.get(position).get("typeT").toString());
        
        //holder.acttype.setTextColor(R.color.white);
        // holder.cBox.setChecked(isSelected.get(position));
        return convertView;
    }

    public final class ViewHolder {

        public TextView title;
        public TextView publisher;
        public TextView timepoint;
        public TextView coins;
        public ImageView userhead;
    }
}
